package com.ls.demo.bean;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.sql.Date;

/**
 * @author liShan
 * @date 2019/9/4 14:39
 */
@Getter
@Setter
@ToString
public abstract class BaseInfo implements Serializable {

    private Long createId;
    private Long modifyId;
    private Date createTime;
    private Date modifyTime;

    public BaseInfo() {
    }

    protected BaseInfo(BaseBuilder baseBuilder) {
        this.createId = baseBuilder.createId;
        this.modifyId = baseBuilder.modifyId;
        this.createTime = baseBuilder.createTime;
        this.modifyTime = baseBuilder.modifyTime;
    }


    public static abstract class BaseBuilder<T extends BaseBuilder<T>>{

        private Long createId;
        private Long modifyId;
        private Date createTime;
        private Date modifyTime;

        /**
         * 返回具体的子类
         * @return 子类的
         */
        abstract T self();

        public BaseBuilder createId(Long createId){
            this.createId = createId;
            return this.self();
        }

        public BaseBuilder modifyId(Long modifyId){
            this.modifyId = modifyId;
            return this.self();
        }

        public BaseBuilder createTime(Date createTime){
            this.createTime = createTime;
            return this.self();
        }

        public BaseBuilder modifyTime(Date modifyTime){
            this.modifyTime = modifyTime;
            return this.self();
        }

    }


}
